<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>

    function getData(url) {
      return new Promise((resolve, reject) => {
        var xhr = new XMLHttpRequest()
        xhr.onreadystatechange = function () {
          if (xhr.readyState == 4) {
            if (xhr.status >= 200 && xhr.status <= 304) {
              resolve(xhr.responseText)
            }
            else {
              reject(xhr.responseText)
            }
          }
        }
        xhr.open('GET', url)
        xhr.send()
      })
    }
    getData('http://localhost:3008/api/student/getstudent').then(result => console.log(result)).catch(err => console.log(err))
    function postData(url, data) {
      return new Promise((resolve, reject) => {
        var xhr = new XMLHttpRequest()
        xhr.onreadystatechange = function () {
          if (xhr.readyState == 4) {
            if (xhr.status >= 200 && xhr.status <= 304) {
              resolve(xhr.responseText)
            }
            else {
              reject(xhr.responseText)
            }
          }
        }
        xhr.open('POST', url)
        xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')
        xhr.send(data)
      })
    }
    postData('http://localhost:3008/api/student/removestudent', 'id=1680229463823').then(result => console.log(result)).catch(err => console.log(err))
    // function postJSONData(url, data) {
    //   return new Promise((resolve, reject) => {
    //     var xhr = new XMLHttpRequest()
    //     xhr.onreadystatechange = function () {
    //       if (xhr.readyState == 4) {
    //         if (xhr.status >= 200 && xhr.status <= 304) {
    //           return resolve(xhr.responseText)
    //         }
    //         else {
    //           return reject(xhr.responseText)
    //         }
    //       }
    //     }
    //     xhr.open('POST', url)
    //     xhr.setRequestHeader('token', 'eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIxIiwiaWF0IjoxNzE1MzIyNDc2LCJleHAiOjE3MTUzNzI1NDF9.1DitdTyoMbk6WjxbFjv8jF7bra3mSbUlm0dVa61TWToJu7N86FUdNVjeuthrAi4241grzl7Kg1M91mPmw6jP9Q')
    //     xhr.setRequestHeader('Content-Type', 'application/json')
    //     xhr.send(data)
    //   })
    // }
    // let p = {
    //   status: '在职',
    //   name: ''
    // }
    // postJSONData('http://192.168.2.57:8090/employee/lists', JSON.stringify(p))
    //   .then(result => console.log(result)).catch(error => console.log(error))
  </script>
</body>

</html>